/**
 * 题目描述
 * 给一 n×n 的字母方阵，内可能蕴含多个 yizhong 单词。单词在方阵中是沿着同一方向连续摆放的。摆放可沿着 8 个方向的任一方向，
 * 同一单词摆放时不再改变方向，单词与单词之间可以交叉，因此有可能共用字母。输出时，将不是单词的字母用 * 代替，以突出显示单词。
 *
 * 输入格式
 * 第一行输入一个数 n。(7≤n≤100)。
 * 第二行开始输入 n×n 的字母矩阵。
 * 输出格式
 * 突出显示单词的 n×n 矩阵。
 *
 * 输入输出样例
 * 输入      输出
 * 7
 * aaaaaaa  *******
 * aaaaaaa  *******
 * aaaaaaa  *******
 * aaaaaaa  *******
 * aaaaaaa  *******
 * aaaaaaa  *******
 * aaaaaaa  *******
 *
 * 输入       输出
 * 8
 * qyizhong  *yizhong
 * gydthkjy  gy******
 * nwidghji  n*i*****
 * orbzsfgz  o**z****
 * hhgrhwth  h***h***
 * zzzzzozo  z****o**
 * iwdfrgng  i*****n*
 * yyyygggg  y******g
 */

/**
 * ********
 * gy*****y
 * n*i***j*
 * o**z*f**
 * h***h***
 * z**z*o**
 * i*d***n*
 * yy*****g
 */

import java.util.*;
import java.io.*;

/**
 * 不说了, 暴力吧 !!
 */

public class Main {
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();

    public static int n;
    public static int[] ax = {1, 2, 3};
    public static int[] bx = {-1, -2, -3};
    public static char[] px = {'z', 'i', 'y'};
    public static char[] cx = {'o', 'n', 'g'};

    public static void main(String[] args) throws IOException {
        // 写代码
        n = in.nextInt();
        char[][] nums = new char[n][n];
        boolean[][] tmp = new boolean[n][n];
        for (int i = 0; i < n; i++) {
            String s = in.nextLine();
            for (int j = 0; j < n; j++) {
                char ch = s.charAt(j);
                nums[i][j] = ch;
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (nums[i][j] == 'h') {
                    if (isTrue1(nums, i, j)) {
                        tmp[i][j] = true;
                        for (int k = 0; k < 3; k++) {
                            // a 下, b 上
                            int a = i + ax[k], b = i + bx[k];
                            tmp[a][j] = true;
                            tmp[b][j] = true;
                        }
                    }
                    if (isTrue2(nums, i, j)) {
                        tmp[i][j] = true;
                        for (int k = 0; k < 3; k++) {
                            // a 左下, b 右上
                            int a1 = i + ax[k], a2 = j + bx[k];
                            int b1 = i + bx[k], b2 = j + ax[k];
                            tmp[a1][a2] = true;
                            tmp[b1][b2] = true;
                        }
                    }
                    if (isTrue3(nums, i, j)) {
                        tmp[i][j] = true;
                        for (int k = 0; k < 3; k++) {
                            // a 右, b 左
                            int a = j + ax[k], b = j + bx[k];
                            tmp[i][a] = true;
                            tmp[i][b] = true;
                        }
                    }
                    if (isTrue4(nums, i, j)) {
                        tmp[i][j] = true;
                        for (int k = 0; k < 3; k++) {
                            // a 右下, b 左上
                            int a1 = i + ax[k], a2 = j + ax[k];
                            int b1 = i + bx[k], b2 = j + bx[k];
                            tmp[a1][a2] = true;
                            tmp[b1][b2] = true;
                        }
                    }
                }
            }
        }

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (tmp[i][j]) {
                    System.out.print(nums[i][j]);
                } else {
                    System.out.print('*');
                }
            }
            System.out.println();
        }
        out.close();
    }

    private static boolean isTrue1(char[][] nums, int i, int j) {

        int tmp = 0;
        // 验证 |, 一遍正序, 一遍倒序
        if (i > 2 && i < n - 3) {
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 下, b 上
                int a = i + ax[k], b = i + bx[k];
                if (nums[a][j] == px[k] && nums[b][j] == cx[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 下, b 上
                int a = i + ax[k], b = i + bx[k];
                if (nums[a][j] == cx[k] && nums[b][j] == px[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
        }
        return false;
    }

    private static boolean isTrue2(char[][] nums, int i, int j) {
        int tmp = 0;
        // 验证 /
        if (i > 2 && i < n - 3 && j > 2 && j < n - 3) {
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 左下, b 右上
                int a1 = i + ax[k], a2 = j + bx[k];
                int b1 = i + bx[k], b2 = j + ax[k];
                if (nums[a1][a2] == px[k] && nums[b1][b2] == cx[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 左下, b 右上
                int a1 = i + ax[k], a2 = j + bx[k];
                int b1 = i + bx[k], b2 = j + ax[k];
                if (nums[a1][a2] == cx[k] && nums[b1][b2] == px[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
        }
        return false;
    }

    private static boolean isTrue3(char[][] nums, int i, int j) {
        int tmp = 0;
        // 验证 --
        if (j > 2 && j < n - 3) {
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 右, b 左
                int a = j + ax[k], b = j + bx[k];
                if (nums[i][a] == px[k] && nums[i][b] == cx[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 右, b 左
                int a = j + ax[k], b = j + bx[k];
                if (nums[i][a] == cx[k] && nums[i][b] == px[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
        }
        return false;
    }
    private static boolean isTrue4(char[][] nums, int i, int j) {
        int tmp = 0;
        if (i > 2 && i < n - 3 && j > 2 && j < n - 3) {
            // 验证 \
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 右下, b 左上
                int a1 = i + ax[k], a2 = j + ax[k];
                int b1 = i + bx[k], b2 = j + bx[k];
                if (nums[a1][a2] == px[k] && nums[b1][b2] == cx[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
            tmp = 0;
            for (int k = 0; k < 3; k++) {
                // a 左下, b 右上
                int a1 = i + ax[k], a2 = j + ax[k];
                int b1 = i + bx[k], b2 = j + bx[k];
                if (nums[a1][a2] == cx[k] && nums[b1][b2] == px[k]) {
                    tmp++;
                } else {
                    break;
                }
                if (tmp == 3) {
                    return true;
                }
            }
        }
        return false;
    }
}

// 自定义快速读入
class Read {
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException {
        while(!st.hasMoreTokens()) {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }

    String nextLine() throws IOException {
        return bf.readLine();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}